Public Class ConnectLog_Factory
    Public Function AverageDayConnectionCounts( _
                            ByVal sDay As String, _
                            ByVal lDatabaseID As Long) As DataTable

        Dim oFactory As New DBConnectLog_Factory

        Return oFactory.AverageDayConnectionCounts(sDay, lDatabaseID)
    End Function

    Public Function AverageDayConnectionCounts( _
                        ByVal sDay As String, _
                        ByVal lDatabaseID As Long, _
                        ByVal iDaysToAverage As Integer) As DataTable

        Dim oFactory As New DBConnectLog_Factory

        Return oFactory.AverageDayConnectionCounts(sDay, lDatabaseID, iDaysToAverage)
    End Function

    Public Function AverageDailyConnectionCounts( _
                            ByVal sWeek As String, _
                            ByVal lDatabaseID As Long, _
                            ByVal lWeeksToInclude As Integer) As DataTable

        Dim oFactory As New DBConnectLog_Factory

        Return oFactory.AverageDailyConnectionCounts(sWeek, lDatabaseID, lWeeksToInclude)
    End Function

    Public Function AverageDailyConnectionCounts( _
                                ByVal sWeek As String, _
                                ByVal lDatabaseID As Long) As DataTable

        Dim oFactory As New DBConnectLog_Factory

        Return oFactory.AverageDailyConnectionCounts(sWeek, lDatabaseID)
    End Function

    Public Function AverageWeeklyConnectionCounts( _
                            ByVal lCountOfWeeks As Long, _
                            ByVal lDatabaseID As Long) As DataTable

        Dim oFactory As New DBConnectLog_Factory

        Return oFactory.AverageWeeklyConnectionCounts(lCountOfWeeks, lDatabaseID)
    End Function

    Public Function ConnectionIsStillAlive( _
                    ByVal lDatabaseID As Long, _
                    ByVal lSPID As Long, _
                    ByVal sHostName As String, _
                    ByVal sLoginName As String, _
                    ByVal sStatus As String, _
                    ByVal lBlockID As Long, _
                    ByVal sCommand As String) As ConnectLog

        Dim oConnectLog As ConnectLog = Nothing

        Dim oFactory As New DBConnectLog_Factory
        Dim lID As Long = oFactory.ConnectionIsStillAlive(lDatabaseID, lSPID, sHostName, sLoginName, sStatus, lBlockID, sCommand)

        If lID <> DBBase.NODATA Then
            oConnectLog = New ConnectLog(lID)
            oConnectLog.Load()
        End If

        Return oConnectLog
    End Function

    Public Function ConnectionsInPeriod( _
                ByVal lDatabaseID As Long, _
                ByVal sStartDate As Date, _
                ByVal sEndDate As Date) As DataTable

        Dim oFactory As New DBConnectLog_Factory
        Return oFactory.ConnectionsInPeriod(lDatabaseID, sStartDate, sEndDate)
    End Function

    Public Sub RemoveExpiredData()
        Dim oConfiguration As New Config_Factory
        Dim iExpirationPeriod As Integer = oConfiguration.GetValueFromName("CONNECTION_RETENTION_PERIOD")

        Dim oFactory As New DBBlockLog_Factory

        oFactory.RemoveExpiredData(iExpirationPeriod)
    End Sub
End Class
